First commit with working display
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
.. example_heading: Message Box
|
||||
|
||||
|
||||
Simple Message box
|
||||
------------------
|
||||
|
||||
.. lv_example:: widgets/msgbox/lv_example_msgbox_1
|
||||
:language: c
|
||||
|
||||
Scrolling and styled Message box
|
||||
--------------------------------
|
||||
|
||||
.. lv_example:: widgets/msgbox/lv_example_msgbox_2
|
||||
:language: c
|
||||
|
||||
Message box with blurred background
|
||||
-----------------------------------
|
||||
|
||||
.. lv_example:: widgets/msgbox/lv_example_msgbox_3
|
||||
:language: c
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * btn = lv_event_get_target_obj(e);
|
||||
lv_obj_t * label = lv_obj_get_child(btn, 0);
|
||||
LV_UNUSED(label);
|
||||
LV_LOG_USER("Button %s clicked", lv_label_get_text(label));
|
||||
}
|
||||
|
||||
void lv_example_msgbox_1(void)
|
||||
{
|
||||
lv_obj_t * mbox1 = lv_msgbox_create(NULL);
|
||||
|
||||
lv_msgbox_add_title(mbox1, "Hello");
|
||||
|
||||
lv_msgbox_add_text(mbox1, "This is a message box with two buttons.");
|
||||
lv_msgbox_add_close_button(mbox1);
|
||||
|
||||
lv_obj_t * btn;
|
||||
btn = lv_msgbox_add_footer_button(mbox1, "Apply");
|
||||
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
|
||||
btn = lv_msgbox_add_footer_button(mbox1, "Cancel");
|
||||
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void minimize_button_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * mbox = (lv_obj_t *) lv_event_get_user_data(e);
|
||||
lv_obj_add_flag(mbox, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
void lv_example_msgbox_2(void)
|
||||
{
|
||||
lv_obj_t * setting = lv_msgbox_create(lv_screen_active());
|
||||
lv_obj_set_style_clip_corner(setting, true, 0);
|
||||
|
||||
/* setting fixed size */
|
||||
lv_obj_set_size(setting, 300, 200);
|
||||
|
||||
/* setting's titlebar/header */
|
||||
lv_msgbox_add_title(setting, "Setting");
|
||||
lv_obj_t * minimize_button = lv_msgbox_add_header_button(setting, LV_SYMBOL_MINUS);
|
||||
lv_obj_add_event_cb(minimize_button, minimize_button_event_cb, LV_EVENT_CLICKED, setting);
|
||||
lv_msgbox_add_close_button(setting);
|
||||
|
||||
/* setting's content*/
|
||||
lv_obj_t * content = lv_msgbox_get_content(setting);
|
||||
lv_obj_set_flex_flow(content, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(content, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
lv_obj_set_style_pad_right(content, -1, LV_PART_SCROLLBAR);
|
||||
|
||||
lv_obj_t * cont_brightness = lv_obj_create(content);
|
||||
lv_obj_set_size(cont_brightness, lv_pct(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(cont_brightness, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(cont_brightness, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * lb_brightness = lv_label_create(cont_brightness);
|
||||
lv_label_set_text(lb_brightness, "Brightness : ");
|
||||
lv_obj_t * slider_brightness = lv_slider_create(cont_brightness);
|
||||
lv_obj_set_width(slider_brightness, lv_pct(100));
|
||||
lv_slider_set_value(slider_brightness, 50, LV_ANIM_OFF);
|
||||
|
||||
lv_obj_t * cont_speed = lv_obj_create(content);
|
||||
lv_obj_set_size(cont_speed, lv_pct(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(cont_speed, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(cont_speed, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * lb_speed = lv_label_create(cont_speed);
|
||||
lv_label_set_text(lb_speed, "Speed : ");
|
||||
lv_obj_t * slider_speed = lv_slider_create(cont_speed);
|
||||
lv_obj_set_width(slider_speed, lv_pct(100));
|
||||
lv_slider_set_value(slider_speed, 80, LV_ANIM_OFF);
|
||||
|
||||
/* footer */
|
||||
lv_obj_t * apply_button = lv_msgbox_add_footer_button(setting, "Apply");
|
||||
lv_obj_set_flex_grow(apply_button, 1);
|
||||
|
||||
lv_obj_t * cancel_button = lv_msgbox_add_footer_button(setting, "Cancel");
|
||||
lv_obj_set_flex_grow(cancel_button, 1);
|
||||
|
||||
lv_obj_t * footer = lv_msgbox_get_footer(setting);
|
||||
lv_obj_set_style_bg_color(footer, lv_palette_main(LV_PALETTE_INDIGO), 0);
|
||||
lv_obj_set_style_bg_opa(footer, LV_OPA_100, 0);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void dropdown_value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * dropdown = lv_event_get_target_obj(e);
|
||||
lv_obj_t * msgbox = (lv_obj_t *)lv_event_get_user_data(e);
|
||||
lv_obj_t * top_layer = lv_layer_top();
|
||||
uint32_t opt = lv_dropdown_get_selected(dropdown);
|
||||
|
||||
/*Blur screen*/
|
||||
if(opt == 0) {
|
||||
lv_obj_set_style_blur_radius(msgbox, 0, 0);
|
||||
lv_obj_set_style_blur_radius(top_layer, 24, 0);
|
||||
}
|
||||
/*Blur Message box*/
|
||||
else {
|
||||
lv_obj_set_style_blur_radius(msgbox, 24, 0);
|
||||
lv_obj_set_style_blur_radius(top_layer, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_example_msgbox_3(void)
|
||||
{
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(label, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
||||
" Ut orci mauris, placerat et euismod eu, ullamcorper eget massa. "
|
||||
"Suspendisse sodales vitae augue ut vestibulum. "
|
||||
"Nunc fringilla leo ut tellus consectetur tincidunt. "
|
||||
"Quisque eu tortor semper odio aliquet congue egestas ac massa. "
|
||||
"Phasellus elit lectus, finibus tempor augue in, elementum lobortis nisl. "
|
||||
"Donec tristique lorem et tincidunt faucibus.\n\n"
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
||||
" Ut orci mauris, placerat et euismod eu, ullamcorper eget massa. "
|
||||
"Suspendisse sodales vitae augue ut vestibulum. "
|
||||
"Nunc fringilla leo ut tellus consectetur tincidunt. "
|
||||
"Quisque eu tortor semper odio aliquet congue egestas ac massa. "
|
||||
"Phasellus elit lectus, finibus tempor augue in, elementum lobortis nisl. "
|
||||
"Donec tristique lorem et tincidunt faucibus.");
|
||||
|
||||
lv_obj_set_width(label, lv_pct(60));
|
||||
lv_obj_center(label);
|
||||
lv_obj_set_style_text_color(label, lv_palette_main(LV_PALETTE_BLUE), 0);
|
||||
|
||||
lv_obj_t * msgbox1 = lv_msgbox_create(lv_layer_top());
|
||||
lv_msgbox_add_title(msgbox1, "Setting");
|
||||
lv_msgbox_add_text(msgbox1, "Hello!\n\n"
|
||||
"Scroll the text in the background to see how it behaves.");
|
||||
|
||||
/*Just a little styling on the message box*/
|
||||
lv_obj_set_style_bg_opa(msgbox1, LV_OPA_40, 0);
|
||||
lv_obj_set_style_bg_opa(lv_msgbox_get_header(msgbox1), LV_OPA_50, 0);
|
||||
lv_obj_set_style_bg_color(lv_msgbox_get_header(msgbox1), lv_color_black(), 0);
|
||||
lv_obj_set_style_bg_color(msgbox1, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_color(msgbox1, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(lv_msgbox_get_header(msgbox1), lv_color_white(), 0);
|
||||
lv_obj_set_style_blur_backdrop(msgbox1, true, 0);
|
||||
|
||||
/*A dropdown to select what to blur*/
|
||||
lv_obj_t * dropdown = lv_dropdown_create(lv_layer_top());
|
||||
lv_dropdown_set_options(dropdown, "Blur screen\nBlur msgbox");
|
||||
lv_obj_set_pos(dropdown, 5, 5);
|
||||
lv_obj_add_event_cb(dropdown, dropdown_value_changed_event_cb, LV_EVENT_VALUE_CHANGED, msgbox1);
|
||||
/*Also make the list blurred*/
|
||||
lv_obj_set_style_blur_radius(lv_dropdown_get_list(dropdown), 24, 0);
|
||||
lv_obj_set_style_blur_backdrop(lv_dropdown_get_list(dropdown), true, 0);
|
||||
lv_obj_set_style_bg_opa(lv_dropdown_get_list(dropdown), LV_OPA_50, 0);
|
||||
|
||||
/*Send a value changed event to set the initial state*/
|
||||
lv_obj_send_event(dropdown, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user