init lvgl code
This commit is contained in:
7
LVGL.Simulator/lvgl/examples/widgets/span/index.rst
Normal file
7
LVGL.Simulator/lvgl/examples/widgets/span/index.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
Span with custom styles
|
||||
""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/span/lv_example_span_1
|
||||
:language: c
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_SPAN && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Create span.
|
||||
*/
|
||||
void lv_example_span_1(void)
|
||||
{
|
||||
static lv_style_t style;
|
||||
lv_style_init(&style);
|
||||
lv_style_set_border_width(&style, 1);
|
||||
lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_ORANGE));
|
||||
lv_style_set_pad_all(&style, 2);
|
||||
|
||||
lv_obj_t * spans = lv_spangroup_create(lv_scr_act());
|
||||
lv_obj_set_width(spans, 300);
|
||||
lv_obj_set_height(spans, 300);
|
||||
lv_obj_center(spans);
|
||||
lv_obj_add_style(spans, &style, 0);
|
||||
|
||||
lv_spangroup_set_align(spans, LV_TEXT_ALIGN_LEFT);
|
||||
lv_spangroup_set_overflow(spans, LV_SPAN_OVERFLOW_CLIP);
|
||||
lv_spangroup_set_indent(spans, 20);
|
||||
lv_spangroup_set_mode(spans, LV_SPAN_MODE_BREAK);
|
||||
|
||||
lv_span_t * span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text(span, "China is a beautiful country.");
|
||||
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_RED));
|
||||
lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_STRIKETHROUGH | LV_TEXT_DECOR_UNDERLINE);
|
||||
lv_style_set_text_opa(&span->style, LV_OPA_50);
|
||||
|
||||
span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text_static(span, "good good study, day day up.");
|
||||
#if LV_FONT_MONTSERRAT_24
|
||||
lv_style_set_text_font(&span->style, &lv_font_montserrat_24);
|
||||
#endif
|
||||
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_GREEN));
|
||||
|
||||
span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text_static(span, "LVGL is an open-source graphics library.");
|
||||
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_BLUE));
|
||||
|
||||
span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text_static(span, "the boy no name.");
|
||||
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_GREEN));
|
||||
#if LV_FONT_MONTSERRAT_20
|
||||
lv_style_set_text_font(&span->style, &lv_font_montserrat_20);
|
||||
#endif
|
||||
lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_UNDERLINE);
|
||||
|
||||
span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text(span, "I have a dream that hope to come true.");
|
||||
|
||||
lv_spangroup_refr_mode(spans);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Create span
|
||||
#
|
||||
style = lv.style_t()
|
||||
style.init()
|
||||
style.set_border_width(1)
|
||||
style.set_border_color(lv.palette_main(lv.PALETTE.ORANGE))
|
||||
style.set_pad_all(2)
|
||||
|
||||
spans = lv.spangroup(lv.scr_act())
|
||||
spans.set_width(300)
|
||||
spans.set_height(300)
|
||||
spans.center()
|
||||
spans.add_style(style, 0)
|
||||
|
||||
spans.set_align(lv.TEXT_ALIGN.LEFT)
|
||||
spans.set_overflow(lv.SPAN_OVERFLOW.CLIP)
|
||||
spans.set_indent(20)
|
||||
spans.set_mode(lv.SPAN_MODE.BREAK)
|
||||
|
||||
span = spans.new_span()
|
||||
span.set_text("china is a beautiful country.")
|
||||
span.style.set_text_color(lv.palette_main(lv.PALETTE.RED))
|
||||
span.style.set_text_decor(lv.TEXT_DECOR.STRIKETHROUGH | lv.TEXT_DECOR.UNDERLINE)
|
||||
span.style.set_text_opa(lv.OPA._30)
|
||||
|
||||
span = spans.new_span()
|
||||
span.set_text_static("good good study, day day up.")
|
||||
#if LV_FONT_MONTSERRAT_24
|
||||
# lv_style_set_text_font(&span->style, &lv_font_montserrat_24);
|
||||
#endif
|
||||
span.style.set_text_color(lv.palette_main(lv.PALETTE.GREEN))
|
||||
|
||||
span = spans.new_span()
|
||||
span.set_text_static("LVGL is an open-source graphics library.")
|
||||
span.style.set_text_color(lv.palette_main(lv.PALETTE.BLUE))
|
||||
|
||||
span = spans.new_span()
|
||||
span.set_text_static("the boy no name.")
|
||||
span.style.set_text_color(lv.palette_main(lv.PALETTE.GREEN))
|
||||
#if LV_FONT_MONTSERRAT_20
|
||||
# lv_style_set_text_font(&span->style, &lv_font_montserrat_20);
|
||||
#endif
|
||||
span.style.set_text_decor(lv.TEXT_DECOR.UNDERLINE)
|
||||
|
||||
span = spans.new_span()
|
||||
span.set_text("I have a dream that hope to come true.")
|
||||
|
||||
spans.refr_mode()
|
||||
|
||||
# lv_span_del(spans, span);
|
||||
# lv_obj_del(spans);
|
||||
|
||||
Reference in New Issue
Block a user