2021-02-08 09:53:03 +01:00
|
|
|
#include "../../../lvgl.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_LABEL && LV_BUILD_EXAMPLES
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a fake text shadow
|
|
|
|
*/
|
|
|
|
void lv_example_label_2(void)
|
|
|
|
{
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Create a style for the shadow*/
|
2021-02-08 09:53:03 +01:00
|
|
|
static lv_style_t style_shadow;
|
|
|
|
lv_style_init(&style_shadow);
|
|
|
|
lv_style_set_text_opa(&style_shadow, LV_OPA_30);
|
2021-02-23 15:03:06 +01:00
|
|
|
lv_style_set_text_color(&style_shadow, lv_color_black());
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Create a label for the shadow first (it's in the background)*/
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * shadow_label = lv_label_create(lv_scr_act());
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_add_style(shadow_label, &style_shadow, 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Create the main label*/
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * main_label = lv_label_create(lv_scr_act());
|
2021-02-08 09:53:03 +01:00
|
|
|
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));
|
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Position the main label*/
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_align(main_label, LV_ALIGN_CENTER, 0, 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Shift the second label down and to the right by 2 pixel*/
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_align_to(shadow_label, main_label, LV_ALIGN_TOP_LEFT, 2, 2);
|
2021-02-08 09:53:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|